package com.aiyige.page.user.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.aiyige.MyApp;
import com.aiyige.R;
import com.aiyige.page.user.DynamicPage;
import com.aiyige.page.user.ProductPage;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by zhuyakun on 2017/10/19.
 */

public class UserViewPagerAdapter extends FragmentPagerAdapter {
    List<Fragment> fragmentList = new LinkedList<>();
    int[] pageTitleResId = {R.string.dynamic_display, R.string.product_service};

    public UserViewPagerAdapter(FragmentManager fm, String userId) {
        super(fm);
        fragmentList.add(DynamicPage.newInstance(userId));
        fragmentList.add(ProductPage.newInstance(userId));
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return MyApp.getAppContext().getString(pageTitleResId[position]);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }
}
